Skip to content

feat: run jobs asynchronously through a Redis-backed worker (RQ) - #18

Merged
danishkumar26 merged 2 commits into
mainfrom
feature/async-job-worker
Nov 26, 2026
Merged

danishkumar26 merged 2 commits into
mainfrom
feature/async-job-worker

Conversation

@danishkumar26

Copy link
Copy Markdown
Owner

Job submission no longer executes the engine inside the HTTP request.

  • Commits the job row as "queued" and enqueues run_job to an RQ jobs queue in Redis; submission returns promptly and clients poll GET /api/v1/jobs/{id}.
  • New backend/app/worker.py: worker entry point (rq worker jobs) — assesses allowlisted targets only, stores assets/asset_observations, marks jobs completed or failed, audits job.execute / job.execute.failed; engine failures never crash the worker or return HTTP 500.
  • Adds redis==5.2.1 and rq==1.16.1, a worker service to docker-compose.yml (plus the pg8000 DATABASE_URL dialect fix per ADR-001), ADR-008, and 5 new run_job tests (test_worker.py). Tests no-op _enqueue and call run_job directly (no Redis in CI).
  • 55/55 tests pass; ruff check, ruff format, and mypy backend/app clean.

Resolves the ADR-007 shortcut (synchronous in-request execution); architecture layers 6 and 8.

Job submission no longer executes the engine inside the HTTP request.
The job row is committed as "queued" and enqueued to an RQ jobs
queue in Redis; a worker process (rq worker jobs) pulls jobs, runs the
registered engine against allowlisted targets only, stores
assets/asset_observations, and marks each job completed or failed with
a job.execute / job.execute.failed audit entry. Engine failures never
crash the worker or return HTTP 500.

Adds backend/app/worker.py (run_job), redis+rq dependencies, a worker
service to docker-compose.yml (with the pg8000 DATABASE_URL dialect
fix per ADR-001), ADR-008, five run_job tests, and updates to
test_jobs.py and conftest.py (no Redis in tests).
@danishkumar26
danishkumar26 merged commit 4686a73 into main Nov 26, 2026
8 checks passed
@danishkumar26
danishkumar26 deleted the feature/async-job-worker branch November 26, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant